package com.kerbores.jongo.marshall.nutz;

import com.kerbores.jongo.Mapper;
import com.kerbores.jongo.ObjectIdUpdater;
import com.kerbores.jongo.marshall.Marshaller;
import com.kerbores.jongo.marshall.Unmarshaller;
import com.kerbores.jongo.query.QueryFactory;

/**
 * @author 王贵源<kerbores>
 *
 *         create at 2015年12月21日 下午5:14:00
 */
public class NutzMapper implements Mapper {

	private NutzMarshallerEngine engine;

	private NutzMapper(NutzMarshallerEngine engine) {
		this.engine = engine;
	}

	public static Mapper create(NutzMarshallerEngine engine) {
		return new NutzMapper(engine);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.jongo.Mapper#getMarshaller()
	 */
	@Override
	public Marshaller getMarshaller() {
		return engine;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.jongo.Mapper#getUnmarshaller()
	 */
	@Override
	public Unmarshaller getUnmarshaller() {
		return engine;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.jongo.Mapper#getObjectIdUpdater()
	 */
	@Override
	public ObjectIdUpdater getObjectIdUpdater() {
		return new NutzObjectIdUpdater(IdFieldSelector.defaultiIdFieldSelector);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.jongo.Mapper#getQueryFactory()
	 */
	@Override
	public QueryFactory getQueryFactory() {
		return new BsonQueryFactory(engine);
	}

}
